package com.ncloud.act.service.impl;
import java.text.ParseException;
import java.util.List;

import javax.annotation.Resource;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ncloud.act.common.ActDataHelper;
import com.ncloud.act.entity.Bill;
import com.ncloud.act.mapper.BillMapper;
import com.ncloud.act.mapper.BsCycleMapper;
import com.ncloud.act.mapper.ChnlMapper;
import com.ncloud.act.service.BillService;
import com.ncloud.common.exception.UserException;

@Service
public class BillServiceImpl implements BillService{
	private static final Logger logger = LogManager.getLogger(BillServiceImpl.class);
	@Resource
	private ChnlMapper chnlMapper;
	@Resource
	private BillMapper billMapper;
	@Resource
	private BsCycleMapper bsCycleMapper;
	@Override
	public JSONArray getBillInfo(JSONObject json) throws ParseException {
		Long acct_id= 0l;
		if(json.containsKey("acct_id"))
		{
			acct_id=json.getLong("acct_id");
		}else{
			throw new UserException("4000", "没有账户编码");
		}
		List<Bill> bills = billMapper.getBillByAcctID(acct_id);
		JSONArray results=JSON.parseArray(JSON.toJSONString(bills));
		ActDataHelper.div100(results, new String[] {"fee","balance","late_fee","late_balance"});
		return results;
	}
}
